
package com.controller.common;

import java.lang.reflect.Field;

/**
 * 解析查询条件字段
 * 
 * @author gmsd100
 *
 */
public class FieldUtil {

	/**
	 * 自定义注解
	 */
	private FieldSearch fieldSearch;

	/**
	 * 反射对象对应属性
	 */
	private Field field;

	/**
	 * 名称
	 */
	private String name;

	/**
	 * 值
	 */
	public String value;

	/**
	 * 反射对象
	 */
	private Class<?> type;

	/**
	 * 初始化反射对象
	 * 
	 * @param search
	 * @param field
	 * @param obj
	 */
	public FieldUtil(FieldSearch fieldSearch, Field field, Object obj) {

		super();
		this.fieldSearch = fieldSearch;
		this.field = field;
		try {
			field.setAccessible(true);
			if (field.get(obj) != null) {
				this.value = field.get(obj).toString();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		this.name = field.getName();
		this.type = field.getType();
	}

	public FieldUtil(FieldSearch fieldSearch, Class<?> type) {

		super();
		this.fieldSearch = fieldSearch;
		this.type = type;
	}

	public FieldSearch getFieldSearch() {

		return fieldSearch;
	}

	public void setMeta(FieldSearch fieldSearch) {

		this.fieldSearch = fieldSearch;
	}

	public Field getField() {

		return field;
	}

	public void setField(Field field) {

		this.field = field;
	}

	public String getName() {

		return name;
	}

	public void setName(String name) {

		this.name = name;
	}

	public Class<?> getType() {

		return type;
	}

	public void setType(Class<?> type) {

		this.type = type;
	}

	public String getValue() {

		return value;
	}

	public void setValue(String value) {

		this.value = value;
	}
}
